package ZuoYe03_YouCanFangFa2_0507;

import java.util.Scanner;

/**
 * 4:计算器calculator用颜色，品牌，价格color, brand, price等属性， 有计算加减乘除add, subtract,
 * multiply and divide 以及算一个数立方cube的方法，用oo的思想模拟。
 * 
 * @author zhaoyang
 *
 */
public class Calc {
	String color;
	String brand;
	double price;

	public double add(double a, double b) {
		return a + b;

	}

	public double subtract(double a, double b) {
		return a - b;

	}

	public double multiply(double a, double b) {
		return a * b;

	}

	public double divide(double a, double b) {
		return a / b;

	}

	public double cube(double a) {
		return a * a * a;

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Calc num = new Calc();
		double a;
		double b;
		Scanner input = new Scanner(System.in);
		while (true) {
			System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>");
			System.out.println("加减乘除请按1，\n求立方请按2，\n退出程序请按0：");
			int flag = input.nextInt();
			if (flag == 1) {

				System.out.println("请输入第一个数：");
				a = input.nextDouble();
				System.out.println("请输入计算符号（+ - * /）：");
				String s = input.next();
				char c = s.charAt(0);
				System.out.println("请输入第二个数：");
				b = input.nextDouble();

				if (c == '+') {
					System.out.println(a + "+" + b + "=" + num.add(a, b));
				} else if (c == '-') {
					System.out.println(a + "-" + b + "=" + num.subtract(a, b));
				} else if (c == '*') {
					System.out.println(a + "*" + b + "=" + num.multiply(a, b));
				} else if (c == '/') {
					System.out.println(a + "/" + b + "=" + num.divide(a, b));
				} else if (c == '/') {
					System.out.println(a + "/" + b + "=" + num.divide(a, b));
				}
			} else if (flag == 2) {
				System.out.println("请输入第一个数：");
				a = input.nextDouble();
				System.out.println(a + "的立方是：" + num.cube(a));
			} else if (flag == 0) {
				System.out.println("程序退出,谢谢使用！");
				break;
			}
		}

	}

}
